feat(media): add sharded media object-key paths - #4533
Conversation
ada0dd3 to
828b51e
Compare
Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Classify sharded payload keys in storage sweeps, preserve physical totals, and deduplicate logical legacy/sharded copies. Export read resolution, fallback, and duplicate-layout metrics. Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Keep self-hosted upgrades on legacy writes by default, expose the write-layout gate through Helm and Compose, and document the explicit legacy-to-dual-to-sharded migration sequence. Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Consolidate read and write policy behind one upgrade-safe phase and ship guarded maintenance binaries for backfill and legacy cleanup. Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Co-authored-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> Signed-off-by: npub128x7j3pwgm4vs8yra3c42fcgcwcvh94g3luwzkqa376du2q6l0esqcrwch <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
Signed-off-by: Brad Seiler <seiler@squareup.com>
Replace the Option + expect("checked above") pattern in both upload
short-circuit paths with a filtered if-let binding, so the presence of
the blob key is guaranteed structurally instead of by a comment on a
non-local invariant. Also collapse the longhand match on
existing_write_key into `?`. No behavior change.
Signed-off-by: Brad Seiler <seiler@squareup.com>
Document that returning to legacy-only after accepting uploads in sharded-only makes sharded-layout objects unreadable until the phase is raised again. Ship sharded-only in the Compose example environment so fresh stacks never need a backfill, and correct the chart README to reflect that only the chart default remains legacy-only for upgrade safety. Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Brad Seiler <seiler@squareup.com> Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Brad Seiler <seiler@squareup.com> Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Brad Seiler <seiler@squareup.com> Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Brad Seiler <seiler@squareup.com> Signed-off-by: Brad Seiler <seiler@squareup.com>
5fc442c to
1cfde28
Compare
tlongwell-block
left a comment
There was a problem hiding this comment.
Requesting changes for two brownfield blockers at head 1cfde2831e3b6512f24630b37f9ef130624d2f4e:
-
Legacy cleanup cannot safely resume from a sidecar checkpoint.
verify_selected_destinationsonly buildsverified_legacy_keysfrom sidecars at/afterBUZZ_MEDIA_MIGRATION_START_AFTER, then deletes those shared flat CAS keys. One legacy key can serve multiple communities (as the function comment correctly notes). If community A sorts before the checkpoint and lacks its sharded copy while community B sorts after it and has a verified sharded copy, the resumed run verifies B, inserts the shared legacy key, and deletes it, stranding A. The README currently tells operators both tools can restart from any logged checkpoint. Either disallowstart_afterfor destructive cleanup or make cleanup prove all sidecar bindings for every candidate legacy key across the full bucket before deletion. Please add the cross-community/resume regression test. -
The stale branch revives the removed Helm media-auth flag without a merge conflict. A no-commit merge of this head into current
origin/maincleanly restoresrelay.requireMediaGetAuth,BUZZ_REQUIRE_MEDIA_GET_AUTH, its schema entry, and render test. Current relay config explicitly classifies that variable as inert because media reads are unconditionally authenticated (crates/buzz-relay/src/config.rs:434-444,810-814). The resulting chart advertises a switch whosefalsevalue does nothing and emits a startup warning. Rebase and drop these unrelated stale additions.
What I traced:
- Media payload read/head/range/stream and imeta checks route through migration candidates; default
legacy-onlypreserves existing flat media reads/writes. - Sidecars and upload records retain their existing namespaces.
- Git store files are untouched; Git keys remain
packs/,manifests/, andrepos/..., and the only shared S3 setting remains the pre-existing addressing style.
Verification at the exact PR head above:
PATH="$PWD/bin:$PATH" cargo test -p buzz-media --all-targets: 119 passed, live-MinIO test ignored.PATH="$PWD/bin:$PATH" cargo test -p buzz-relay --all-targets: 879 passed across lib/bin, 40 ignored, 0 failed.git diff --check: clean.- Current GitHub checks are green, but they do not exercise destructive cleanup resumption.
Ratings: Minimalness 6/10 (large but mostly justified migration surface; stale unrelated Helm flag is not), Elegance 8/10 (phase model and centralized key derivation are clear; cleanup checkpoint contract is misleading), Correctness 6/10 (upgrade default and live read paths look sound, but the destructive brownfield edge can cause data loss and the clean merge revives inert config). Not ready until both blockers are resolved.
Why
Media payload keys are currently flat, so high-volume traffic lacks hash-leading S3 prefix entropy. Existing deployments also need a safe, explicit rollout that preserves old reads and rollback behavior without changing storage behavior merely by upgrading.
What
media/<sha[0:2]>/<sha[2:4]>/<community>/<filename>while leaving Git/CAS namespaces unchangedBUZZ_MEDIA_MIGRATION_PHASEwith three complete media object-key path policies:legacy-only(default): read and write only legacy paths, preserving existing deployment behaviordual-read-and-write: prefer sharded reads with legacy fallback and write both pathssharded-only: read and write only sharded pathslegacy-only→dual-read-and-write→ backfill →sharded-onlysharded-onlybefore their first upload, avoiding any future backfill or legacy cleanupbuzz-media-layout-backfillandbuzz-media-layout-delete-legacyin both relay image targets, with bounded paging, checkpoints, request-rate limiting, idempotency, destination verification, dry-run, and destructive confirmationValidation
cargo test -p buzz-media --all-targets: 119 passed; live-MinIO test ignoredcargo test -p buzz-relay --lib config::tests::: 32 passedcargo test -p buzz-relay --lib storage_sweep: 15 passedcargo clippy -p buzz-media -p buzz-relay --all-targets -- -D warnings: cleancargo fmt --all -- --check, desktop Tauri fmt, andgit diff --check: cleanorigin/main: Rust, desktop, Tauri, mobile, and typecheck suites passedGenerated with Goose